#include <iostream>
#include <string>
#include <algorithm>
#include <time.h>
#include <vector>

using namespace std;

//根据二叉树创建字符串
class Solution {
public:
    string tree2str(TreeNode* root) 
    {
        if(root == nullptr)
            return "";
        
        string s;
        s += to_string(root->val);

        if(root->left != nullptr || root->right != nullptr)
        {
            s += '(';
            s += tree2str(root->left);
            s += ')';
        }

        if(root->right != nullptr)
        {
            s += '(';
            s += tree2str(root->right);
            s += ')';
        }

        return s;
    }

    
};

int main()
{
	return 0;
}